//通过专辑id查看专辑
var albumId = document.location.href.split('=')[1]
var whole=document.getElementsByClassName('whole')[0];
console.log(albumId);
lookedit()
function lookedit() {
    axios({
        method: 'get',
        url: '/album/lookalbum',
        params: {
            albumId: albumId
        }
    }).then(data=>{
        

whole.innerHTML=`<div class="box">
<div class="leftpic"><img src="${data.data.data.data.cover}" alt=""></div>
<div class="toptitle">${data.data.data.data.name}</div>

<div class="bottomtime">${data.data.data.data.time}</div>
<div class="bottomoperate">  <span><i class="fa fa-thumbs-o-up"></i>${data.data.data.data.thumbUp}</span>

<span><i class="fa fa-heart-o"></i>${data.data.data.data.collect}</span>
<span><i class="fa fa-eye"></i>${data.data.data.data.visit}</span></div>
</div>`
    }).catch(err=>{
console.log(err);
    })
}




var pagenow=1,pagesize=6;
var spantwo=document.getElementsByClassName('spantwo')[0]
var tizi=document.getElementsByClassName('tizi')[0]
var tiziContent=document.getElementsByClassName('tiziContent')[0]
console.log(spantwo);
looktizi()
//查看专辑内的帖子
function looktizi(){
    console.warn(pagenow);
axios({
    method:'get',
    url:'/album/checkForumByAlbumId',
    params: {
        albumId: albumId,
        pageNo:pagenow,
        pageSize:pagesize
    }
}).then(data=>{
    console.log(data.data.data.data);
    console.log();
 if(data.data.data.data===null){
    tizi.innerHTML+=`<div class='empty'>该专辑内暂时没有帖子</div>`
  }else if(data.data.data.data.total<pagesize){
    const list = data.data.data.data.list
       pagesize=data.data.data.data.total
       for(j=0;j<pagesize-1;j++){
        tiziContent.innerHTML+=`
        <div>
            <div class="toptu"><img src="${list[j].path}"></div>                            }"></div>
            <div class="bottomcoment">
           <a href=''  id=${list[j].id}> <h3>${list[j].name}</h3></a>
            <img src='${list[j].portrait}'>
            <span>${list[j].context}</span>
          <h4>${list[j].time}</h4></div>
        </div>`}
        for(var i=1;i<=data.data.data.data.pages;i++){
            spantwo.innerHTML+=`
            <span class="pagenum" onclick=getpage()  name='${i}'>${i}</span>`
          }
   
}else{
    const list = data.data.data.data.list
    console.log(list);
   
   if(list.length<pagesize){
 pagesize=list.length
 tiziContent.innerHTML=''
 let str=''
 spantwo.innerHTML=''
 let nums=''

 for(j=0;j<pagesize;j++){
     str+=`<div>
         <div class="toptu"><img src="${list[j].path}"></div>           
         <div class="bottomcoment">
        <a href=''  id=${list[j].id}> <h3>${list[j].name}</h3></a>
         <img src='${list[j].portrait}'>
         <span>${list[j].context}</span>
       <h4>${list[j].time}</h4></div>
     </div>`}
     tiziContent.innerHTML=str
     
     for(var i=1;i<=data.data.data.data.pages;i++){
         if(i==index){
             nums+=`
             <span class="pagenum active" onclick=getpage(this)  name='${i}'>${i}</span>`
         }else{
             nums+=`
             <span class="pagenum " onclick=getpage(this)  name='${i}'>${i}</span>`
         }
       
     }
 spantwo.innerHTML=nums

   }else{
    tiziContent.innerHTML=''
    let str=''
    spantwo.innerHTML=''
    let nums=''
  
    for(j=0;j<pagesize;j++){
        str+=`<div>
            <div class="toptu"><img src="${list[j].path}"></div>           
            <div class="bottomcoment">
           <a href=''  id=${list[j].id}> <h3>${list[j].name}</h3></a>
            <img src='${list[j].portrait}'>
            <span>${list[j].context}</span>
          <h4>${list[j].time}</h4></div>
        </div>`}
        tiziContent.innerHTML=str
        
        for(var i=1;i<=data.data.data.data.pages;i++){
            if(i==index){
                nums+=`
                <span class="pagenum active" onclick=getpage(this)  name='${i}'>${i}</span>`
            }else{
                nums+=`
                <span class="pagenum " onclick=getpage(this)  name='${i}'>${i}</span>`
            }
          
        }
    spantwo.innerHTML=nums
   }
  
}
}).catch(err=>{
    console.log(err);
    alert('no')
})
  
}
    let index=1
//点击分页按钮获取当前页数
getpage=function(e){
 
    looktizi()
   
// e = e || window.event;
//     var target = e.target || e.srcElement;
    pagenow= e.getAttribute('name')
    console.log(pagenow);
index=pagenow
{} 


}